package ln.javatest.day10.demo01;

import java.util.Objects;

public class Demo03Objects {
    public static void main(String[] args) {
        String s1 = "null";
        String s2 = "abc";
        //boolean b = s1.equals(s2);//出现了空指针异常
        //System.out.println(b);
        /*
        Objects类的equals方法：对两个对象进行比较，防止空指针异常。
        */
        boolean b2 = Objects.equals(s1,s2);
        System.out.println(b2);  //false
    }

}
